using Godot;
using System;

public partial class Buff : PanelContainer
{
	public BuffEntity Entity;

	TextureRect icon;
	Label labelStack;
	Label labelDuration;

	public override void _Ready()
	{
		icon = GetNode<TextureRect>("Icon");
		labelStack = GetNode<Label>("Icon/LabelStack");
		labelDuration = GetNode<Label>("Icon/LabelDuration");
	}

	public void Init(BuffEntity entity)
	{
		Entity = entity;
		UpdateUI();
	}

	public void UpdateUI()
	{
		icon.Texture = GameUtil.GetBuffIcon(Entity.Icon);
		if (Entity.IsStackable)
		{
			labelStack.Text = Entity.Stack.ToString();
		}
		else
		{
			labelStack.Hide();
		}
		if (Entity.Duration > 0)
		{
			labelDuration.Text = Entity.Duration.ToString();
		}
		else
		{
			labelDuration.Hide();
		}
	}
}
